package opp.Chickens;

public class rabbit {

        public static void main(String[] args) {
            //鸡兔同笼，鸡兔一共35只，笼子里脚一共94只，请问分别有多少只兔子和多少只鸡？
            int foot = 94;//笼子里一共94只脚
            int sum = 35;//鸡兔一共35只

            for (int chicken = 1; chicken <= foot / 2; chicken++) {//鸡的数量
                int rabbit = sum - chicken;//兔子的数量
                if(rabbit * 4 + chicken * 2 == foot){
                    System.out.println("兔子的只数为" + rabbit);
                    System.out.println("鸡的只数为 " + chicken);
                }
            }
        }
    }


